from appium import webdriver
from appium.webdriver.common.touch_action import TouchAction
import time

# Appium Server 配置
desired_caps = {
    'platformName': 'Android',
    'deviceName': 'Custom Phone',
    'platformVersion': '13.0',
    'appPackage': 'com.google.android.calendar',
    'appActivity': '.activities.CalendarActivity',
    'noReset': True
}

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
action = TouchAction(driver)

# 轻敲操作
try:
    button = driver.find_element('id', 'button')
    action.tap(button).perform()
    print("轻敲操作完成")
except Exception as e:
    print(f"发生错误：{e}")
finally:
    driver.quit()